package vn.student.mylib;

import vn.student.R;
import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.TimePicker;

public class TimeTimeDialog implements android.content.DialogInterface.OnClickListener {
	public static void viewDialog(String title,String[] timeStart, String[] timeEnd, Context ctx,android.content.DialogInterface.OnClickListener onOkClickListener){
		 
		LayoutInflater li = LayoutInflater.from(ctx); 
		View view = li.inflate(R.layout.time_time_dialog, null); 
		
		if(timeStart!=null){
			TimePicker tmp = ((TimePicker) view.findViewById(R.id.timeStartPicker));
			tmp.setCurrentHour(Integer.valueOf(timeStart[0]));
			tmp.setCurrentMinute(Integer.valueOf(timeStart[1]));
		}
		if(timeEnd!=null){
			TimePicker tmp = ((TimePicker) view.findViewById(R.id.timeEndPicker));
			tmp.setCurrentHour(Integer.valueOf(timeEnd[0]));
			tmp.setCurrentMinute(Integer.valueOf(timeEnd[1]));
		}
		
		AlertDialog.Builder builder = new AlertDialog.Builder(ctx); 
		builder.setTitle(title); 
		builder.setView(view); 
		  
		builder.setPositiveButton("OK", onOkClickListener); 
		builder.setNegativeButton("Cancel", new DateDateDialog()); 
		   
		//get the dialog 
		AlertDialog ad = builder.create(); 
		
		ad.show(); 
	}
	@Override
	public void onClick(DialogInterface dialog, int which) {
		// Do notthing.
	}
}